package com.lanhe.game.SysAppuser;

import com.lanhe.common.constant.HttpStatus;
import com.lanhe.common.core.controller.BaseController;
import com.lanhe.common.core.domain.AjaxResult;
import com.lanhe.common.exception.ServiceException;
import com.lanhe.common.utils.StringUtils;
import com.lanhe.framework.web.service.AppLoginService;
import com.lanhe.game.sysAppUser.service.ISysAppUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/api/sysAppUser")
public class ApiSysAppUsrController extends BaseController {


    @Autowired
    private AppLoginService appLoginService;

    @Autowired
    private ISysAppUserService sysAppUserService;

    @GetMapping(value = "/{appUserId}")
    public AjaxResult getInfo(@PathVariable("appUserId") String appUserId)
    {
        return success(sysAppUserService.selectAppuserId(appUserId));
    }

    @PostMapping("/xianfengLogin")
    public Map<String, Object> xianfenLogin(String mobile,String packageName, String code){
        if (StringUtils.isEmpty(mobile)){
            System.err.println("mobile ");
            throw new ServiceException("手机号为空", HttpStatus.ERROR);
        }
        if (StringUtils.isEmpty(code)){
            System.err.println("code");
            throw new ServiceException("验证码是空", HttpStatus.ERROR);
        }
        if (StringUtils.isEmpty(packageName)){
            System.err.println("packageName");
            throw new ServiceException("包名为空",HttpStatus.ERROR);
        }
       return appLoginService.setXianfenLogin(mobile,packageName,code);

    }
}
